package com.etl.dataflow.executor.core;

import java.util.Optional;

public class TaskContextHolder {
    public static final InheritableThreadLocal<TaskContext> THREAD_LOCAL = new InheritableThreadLocal<>();

    public static Optional<TaskContext> getTaskContext() {
        return Optional.ofNullable(THREAD_LOCAL.get());
    }

    static void setTaskContext(TaskContext taskContext) {
        THREAD_LOCAL.set(taskContext);
    }

    static void removeTaskContext() {
        THREAD_LOCAL.remove();
    }
}
